package erresp

import "net/http"

// 错误码规则:
// ----------------------------------------------------------
//     HTTP状态码     自定义错误码     错误内容	    错误提示
// ----------------------------------------------------------
var (
	// 100+ 成功
	OK = register(http.StatusOK, 10000, "ok", "操作成功")
	// 10000 ~ 10099  服务内部错误
	Err        = register(http.StatusInternalServerError, 10001, "internal server failed", "内部服务错误")
	Unknown    = register(http.StatusInternalServerError, 10002, "unknown failed", "未知错误")
	DB         = register(http.StatusInternalServerError, 10003, "internal db failed", "数据库相关错误")
	Redis      = register(http.StatusInternalServerError, 10004, "internal redis failed", "REDIS相关错误")
	GRPC       = register(http.StatusInternalServerError, 10005, "internal grpc failed", "GRPC相关错误")
	ThirdParty = register(http.StatusInternalServerError, 10006, "call third party failed", "调用第三方异常")

	// 11000 ~ 11999 通用业务错误
	ParamInvalid     = register(http.StatusBadRequest, 11001, "invalid param", "请求参数错误")
	FrequencyExceeds = register(http.StatusTooManyRequests, 11002, "request too frequent", "请求过于频繁，请稍后再试")
	NotFound         = register(http.StatusBadRequest, 11003, "not found", "不存在")
	Existed          = register(http.StatusBadRequest, 11004, "already existed", "已存在")
	NoPermission     = register(http.StatusBadRequest, 11005, "no permission", "无权限")
	TokenExpired     = register(http.StatusUnauthorized, 11006, "token is expired", "token已过期")
	TokenNotValidYet = register(http.StatusUnauthorized, 11007, "token not valid yet", "token尚未生效")
	TokenEmpty       = register(http.StatusUnauthorized, 11008, "empty token", "token不能为空")
	TokenInvalid     = register(http.StatusUnauthorized, 11009, "invalid token", "无效token")

	// 12000+ 用户相关
	UserNotFound  = register(http.StatusBadRequest, 12001, "user does not exist", "用户不存在")
	WrongPassword = register(http.StatusBadRequest, 12002, "wrong password", "密码错误")
)
